import {request} from './request'

// 从数据库接口请求省份城市数据
export function getCity(pid=0) {
    return request({
        url: `/api/city?pid=${pid}`,
        method: 'get'
    })
}
// 获取地址列表
export function getAddressList(){
    return request({
        url:'/api/address',
        method:'get',
    })
}
// 获取地址详情
export function getAddressDetail(id){
    return request({
        url:`/api/address/${id}`,
        method:'get',
    })
}

// 添加地址
export function addAddress(params){
    return request({
        url:'/api/address',
        method:'post',
        params
    })
}

// 修改地址
export function editAddress(id,params){
    return request({
        url:`/api/address/${id}`,
        method:'put',
        params
    })
}

// 删除地址
export function delAddress(id){
    return request({
        url:`/api/address/${id}`,
        method:'delete',
        id
    })
}

// 设置默认地址
export function setDefaultAddress(id){
    return request({
        url:`/api/address/${id}/default`,
        method:'patch',
        id
    })
}